/*
 *接口编写处...
*如果接口需要做Action的权限验证，请在Action上使用属性
*如: [ApiActionPermission("fk_reimfloat",Enums.ActionPermissionOptions.Search)]
 */
using Microsoft.AspNetCore.Mvc;
using System;
using System.Collections.Generic;
using System.Threading.Tasks;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.AspNetCore.Http;
using VOL.Entity.DomainModels;
using VOL.System.IServices;
using VOL.Core.Filters;
using VOL.Core.DBManager;
using VOL.System.Repositories;
using System.Linq;
using VOL.Core.Utilities;
using VOL.Core.Extensions;
using VOL.Core.Float;
using Newtonsoft.Json;
using VOL.Core.ManageUser;
using MyErp.Repositories;

namespace VOL.System.Controllers
{
    public partial class fk_reimfloatController
    {
        private readonly Ifk_reimfloatService _service;//访问业务代码
        private readonly IHttpContextAccessor _httpContextAccessor;

        [ActivatorUtilitiesConstructor]
        public fk_reimfloatController(
            Ifk_reimfloatService service,
            IHttpContextAccessor httpContextAccessor
        )
        : base(service)
        {
            _service = service;
            _httpContextAccessor = httpContextAccessor;
        }
        [HttpPost, Route("GetPageData")]
        [ApiActionPermission()]
        public override ActionResult GetPageData([FromBody] PageDataOptions loadData)
        {
            return base.GetPageData(loadData);
        }
        /// <summary>
        /// 获取业务的流程数据
        /// </summary>
        /// <param name="reim_id">业务GUID</param>
        /// <returns></returns>
        [HttpPost, Route("get_curr_reimfloat")]//,AllowAnonymous
        public dynamic get_curr_reimfloat(Guid reim_id)
        {
           var ff = fk_reimfloatRepository.Instance.FindAsIQueryable(f => f.reimid == reim_id).OrderByDescending(o=>o.pxm).ToList();
           return ff;
        }
        private WebResponseContent webResponse = new WebResponseContent();
        

        /// <summary>
        /// 获取当前登录人的信息给前端使用
        /// </summary>
        /// <returns></returns>
       [HttpPost, Route("get_user_info")]//,AllowAnonymous
        public dynamic get_user_info()
        {
            var user = UserContext.Current.GetUserInfo(UserContext.Current.UserId);
            return user;
        }
        /// <summary>
        /// 设置提醒信息为已读
        /// </summary>
        /// <returns></returns>
        [HttpPost, Route("set_readed")]//,AllowAnonymous
        public dynamic set_readed(Guid fk_reimhandle_id)
        {
            var tt = DBServerProvider.DbContext.Set<fk_reimhandle>().Where(s => s.fk_reimhandle_id == fk_reimhandle_id).FirstOrDefault();
            tt.isread = 1;
            tt.readtime = DateTime.Now;
            DBServerProvider.DbContext.Update(tt);
            DBServerProvider.DbContext.SaveChanges();
            
            return "ok";
        }

    }
}
